/*
 * =====================================================================================
 *    Description:  find the counterfeit coin using brute force
 *        Version:  1.0
 *        Created:  09/12/2012 08:31:06 PM
 * =====================================================================================
 */
#include	<stdio.h>
#include	<string.h>
#include	<string>
using std::string;

typedef struct teamData_s
{
    char leftcoins[16];
    char rightcoins[16];
    int  res;
}teamData;

static teamData teams[4];// = {{0x00}};//{0x00}, 0};
static char mark[16];
//static string resMapStr[3] = {"null", "heavy", "light"};
static int blanceMap[2][3] = {{0,1,2}, {0, 2, 1}};

int searchRes(int idx)
{
    int res = 0;
    for (int i = 0; i < 3; ++i)
    {
        int tempres = teams[i].res;
        int balance;
        //all three even impossible
        if (tempres == 0)
            continue;
        if (teams[i].leftcoins[idx] != 0) {
            balance = blanceMap[0][tempres];
        } else if (teams[i].rightcoins[idx] != 0) {
            balance = blanceMap[1][tempres];
        } else 
		   return 0;
        if (res == 0) {
            res = balance;
        } else if (res != balance)
            return 0;
    }
    return res;
}

char leftStr[8], rightStr[8], resStr[8];
int main(int argc, char *argv[])
{
    int n;
    while (scanf("%d", &n) == 1)
    {
        for (int k = 0; k < n; ++k)
        {
            memset(mark, 0x00, sizeof(mark));
            memset(teams, 0x00, sizeof(teams));
            for (int i = 0; i < 3; ++i)
            {
                scanf("%s%s%s", leftStr, rightStr, resStr);
                int len = strlen(leftStr);
                for (int j = 0; j < len; ++j)
                {
                    teams[i].leftcoins[(int)leftStr[j]-'A'] = 1;
                    teams[i].rightcoins[(int)rightStr[j]-'A'] = 1;
                }
                if (strcmp(resStr, "even") == 0) {
                    teams[i].res = 0;
                    for (int g = 0; g < 16; ++g)
                        mark[g] |= (teams[i].leftcoins[g] | teams[i].rightcoins[g]);
                } else if (strcmp(resStr, "up") == 0)
                    teams[i].res = 1;
                else 
                    teams[i].res = 2;
            }
            for (int i = 0; i < 12; ++i)
            {
                if (mark[i] == 0) {
                    int res = searchRes(i);
                    if (res > 0) {
                        char ch = i + 'A';
                        printf ( "%c is the counterfeit coin and ", ch);
                        if (res == 1)
                            printf ( "it is heavy.\n" );
                        else 
                            printf ( "it is light.\n" );
                    }
                }
            }
        }
    }
}
